home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 103
/
Vol 103.iso
/
games
/
starship.swf
/
scripts
/
DefineSprite_220
/
frame_1
/
DoAction.as
Wrap
Text File
|
2010-03-13
|
5KB
|
256 lines
function bump()
{
if(sensorHBump[i] == "left")
{
if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
{
if(0 < vx)
{
vx *= bumpAmount;
}
_X = _X - 1;
}
}
else if(sensorHBump[i] == "right")
{
if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
{
if(vx < 0)
{
vx *= bumpAmount;
}
_X = _X + 1;
}
}
if(sensorVBump[i] == "up")
{
if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
{
if(0 < vy)
{
vy *= bumpAmount;
}
_Y = _Y - 1;
}
}
else if(sensorVBump[i] == "down")
{
if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
{
if(vy < 0)
{
vy *= bumpAmount;
}
if(i == 9)
{
_Y = _Y + 1;
}
}
}
bumpDamage();
}
function bumpDamage()
{
if(harmfulSpeed < actSpeed)
{
actEnergy -= actSpeed - harmfulSpeed;
if(actEnergy < 0)
{
actEnergy = 0;
refreshEnergy();
gotoAndPlay(18);
}
else
{
refreshEnergy();
}
}
}
function burnFuel()
{
_root.fuel.gotoAndStop(int(actFuel / maxFuel * 199) + 1);
}
function refreshLives()
{
if(lives < 4)
{
_root.lives.gotoAndStop(actLives + 1);
}
else
{
_root.lives.gotoAndStop(5);
}
}
function refreshShots()
{
if(shots < 9)
{
_root.shots.gotoAndStop(actShots + 1);
}
else
{
_root.shots.gotoAndStop(10);
}
}
function refreshEnergy()
{
_root.energy.gotoAndStop(int(actEnergy / maxEnergy * 199) + 1);
}
function initObjects()
{
i = 1;
while(_root.cst.maxObjects >= i)
{
tellTarget("../matter/active/object_" + i)
{
init();
}
i++;
}
i = 1;
while(_root.cst.maxMonster >= i)
{
tellTarget("../matter/danger/monster_" + i)
{
init();
ready = true;
}
i++;
}
}
function fillUp()
{
actFuel = maxFuel;
actEnergy = maxEnergy;
actShots = maxShots;
refreshLives();
refreshShots();
refreshEnergy();
burnFuel();
}
function completeCollisionCheck()
{
collision = false;
if(_parent.matter.danger.hitTest(_X + sensorX[0],_Y + sensorY[0] - 2,true))
{
gotoAndPlay(18);
}
if(_parent.matter.danger.hitTest(_X + sensorX[1],_Y + sensorY[1] - 2,true))
{
gotoAndPlay(18);
}
if(_parent.matter.danger.hitTest(_X + sensorX[2],_Y + sensorY[2] - 4,true))
{
gotoAndPlay(18);
}
if(_parent.matter.hitTest(_X + sensorX[5],_Y + sensorY[5],true))
{
collision = true;
}
if(_parent.matter.hitTest(_X + sensorX[6],_Y + sensorY[6],true))
{
collision = true;
}
if(_parent.matter.hitTest(_X + sensorX[7],_Y + sensorY[7],true))
{
collision = true;
}
if(_parent.matter.hitTest(_X + sensorX[8],_Y + sensorY[8],true))
{
collision = true;
}
if(_parent.matter.hitTest(_X + sensorX[9],_Y + sensorY[9],true))
{
collision = true;
}
}
function checkBorderCollision()
{
if(_X + sensorX[5] < 0)
{
vx = Math.abs(vx * bumpAmount);
_X = - sensorX[5];
}
if(550 < _X + sensorX[6])
{
vx = Math.abs(vx) * bumpAmount;
_X = 550 - sensorX[6];
}
if(_Y + sensorY[9] < 0)
{
vy = Math.abs(vy * bumpAmount);
_Y = - sensorY[9];
}
if(339 < _Y)
{
vy = Math.abs(vy) * bumpAmount;
_Y = 339;
}
}
actLevel = _root.startlevel;
_parent.matter.active.gotoAndStop(actLevel);
_parent.matter.platform.gotoAndStop(actLevel);
_parent.matter.danger.gotoAndStop(actLevel);
maxFuel = 1000;
burnFuelUp = 2;
burnFuelSide = 1;
maxEnergy = 200;
maxShots = 5;
actLives = 3;
if(actScore eq "")
{
actScore = 0;
}
actTime = _root.cst.timePerScreen;
harmfulSpeed = 1;
ay = -0.5;
ax = 0.5;
ground = true;
sensorX = new Array();
sensorY = new Array();
sensorHBump = new Array();
sensorVBump = new Array();
sensorX[0] = -11;
sensorY[0] = 0;
sensorHBump[0] = "right";
sensorVBump[0] = "up";
sensorX[1] = 11;
sensorY[1] = 0;
sensorHBump[1] = "left";
sensorVBump[1] = "up";
sensorX[2] = 0;
sensorY[2] = 2;
sensorHBump[2] = "";
sensorVBump[2] = "up";
sensorX[3] = -8;
sensorY[3] = -4;
sensorHBump[3] = "right";
sensorVBump[3] = "up";
sensorX[4] = 8;
sensorY[4] = -4;
sensorHBump[4] = "left";
sensorVBump[4] = "up";
sensorX[5] = -13;
sensorY[5] = -11;
sensorHBump[5] = "right";
sensorVBump[5] = "";
sensorX[6] = 13;
sensorY[6] = -11;
sensorHBump[6] = "left";
sensorVBump[6] = "";
sensorX[7] = -7;
sensorY[7] = -4;
sensorHBump[7] = "right";
sensorVBump[7] = "down";
sensorX[8] = 7;
sensorY[8] = -4;
sensorHBump[8] = "left";
sensorVBump[8] = "down";
sensorX[9] = 0;
sensorY[9] = -21;
sensorHBump[9] = "";
sensorVBump[9] = "down";
sensorX[10] = 0;
sensorY[10] = -7;
bumpAmount = -0.2;